package com.qf.ssm.controller;

import com.github.pagehelper.PageInfo;
import com.qf.ssm.dto.R;
import com.qf.ssm.pojo.RoleMenu;
import com.qf.ssm.service.RoleMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/test")
public class RoleMenuController {

    private RoleMenuService roleMenuService;

    @Autowired
    public void setRoleMenuService(RoleMenuService roleMenuService) {
        this.roleMenuService = roleMenuService;
    }

    @PostMapping("/test")
    public R addRoleMenu(@RequestBody RoleMenu roleMenu){
        roleMenuService.addRoleMenu(roleMenu);
        return R.setOK();
    }

    @PutMapping("/test")
    public R updateRoleMenu(@RequestBody RoleMenu roleMenu){
        roleMenuService.updateRoleMenu(roleMenu);
        return R.setOK();
    }

    @DeleteMapping("/test1")
    public R deleteRoleMenuByIds(Long []ids){
        roleMenuService.deleteRoleMenuByIds(ids);
        return R.setOK();
    }

    @GetMapping("/test2")
    public R findAllRoleMenu(){
        List<RoleMenu> roleMenuList = roleMenuService.findAllRoleMenu();
        return R.setOK(roleMenuList);

    }
}
